#include <bits/stdc++.h>

using namespace std;

map<vector<vector<int>>, int> mem;

int dfs(vector<vector<int>>& nums, vector<int>& ak){
    if(mem.find(nums) != mem.end()){
        return mem[nums];
    }
    int temp = 1e9, s = 0;
    for(int i=0;i<nums.size();i++){
        if(ak[nums[i][1]]) continue;
        for(int j=0;j<nums.size();j++){
            if(j == i ) continue;
            if(nums[j][0] >= nums[i][0]) break;
            s = 1;
            vector<int> remove = nums[j];
            ak[nums[i][1]] = 1;
            nums.erase(nums.begin() + j);
            temp = min(temp, dfs(nums, ak));
            mem[nums] = temp;
            nums.insert(nums.begin() + j, remove);
            ak[nums[i][1]] = 0;

        }
    }
    if(s != 0){
        return temp;
    }else{
        return nums.size();
    }
}

bool cmp(vector<int>& a , vector<int>& b){
    return a[0]<b[0];
}

//CSP-1
int main()
{
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);

    int n;
    cin>>n;
    vector<vector<int>> nums(n+1, vector<int>(2,0));
    vector<int> ak(n+1,0);
    for(int i=0;i<n;i++){
        cin >> nums[i][0];
        nums[i][1] = i;
    }


    sort(nums.begin(), nums.end(), cmp);

    cout<<dfs(nums, ak);


    return 0;
}
